//
//  IntegralShopCell.swift
//  ShareUmbrella
//
//  Created by duanmingyang on 2017/9/13.
//  Copyright © 2017年 尧尚信息科技. All rights reserved.
//

import UIKit
import SDWebImage

class IntegralShopCell: UITableViewCell{
    
    let kScreenHeight = UIScreen.main.bounds.size.height
    let kScreenWidth = UIScreen.main.bounds.size.width
    
    var goodImg:UIImageView?
    var titleLabel:UILabel?
    var priceLabel:UILabel?
    var shopCar:UIButton?
    
    required init?(coder aDecoder:NSCoder) {
        super.init(coder: aDecoder)
    }
    
    override init(style:UITableViewCellStyle, reuseIdentifier:String?) {
        
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.backgroundColor = RGB(r: 247, 247, 248)
        self.setUpUI();
    }
    
    func setUpUI() {
        
        //头像
        goodImg = UIImageView.init(frame: CGRect(x: 20, y: 15, width: 80, height: 80))
        goodImg?.image = UIImage.init(named: "雨伞")
        self.addSubview(goodImg!)
        
        //文字信息
        titleLabel = UILabel.init()
        titleLabel?.backgroundColor = UIColor.clear;
        titleLabel?.frame = CGRect(x:115, y:15, width:kScreenWidth-115, height:20)
        titleLabel?.text = "小熊饼干150g商品"
        titleLabel?.textColor = RGB(r: 60, 60, 60)
        titleLabel?.font = UIFont.systemFont(ofSize: 18)
        addSubview(self.titleLabel!)
        
        
        //积分
        priceLabel = UILabel.init()
        priceLabel?.backgroundColor = UIColor.clear;
        priceLabel?.frame = CGRect(x:115, y:65, width:kScreenWidth-115, height:20)
        priceLabel?.text = "1000积分"
        priceLabel?.textColor = RGB(r:255, 114, 0)
        priceLabel?.font = UIFont.systemFont(ofSize: 14)
        addSubview(self.priceLabel!)
        
        //购物车
        shopCar = UIButton(type:UIButtonType.custom)
        shopCar?.frame = CGRect(x:kScreenWidth-70, y:40, width:50, height:50)
        shopCar?.setImage(UIImage(named:"积分兑换"),for:.normal)
        addSubview(self.shopCar!)

    }
    
    //RGB
    func RGB(r:CGFloat,_ g:CGFloat,_ b:CGFloat) -> UIColor{
        return UIColor(red: (r)/255.0, green: (g)/255.0, blue: (b)/255.0, alpha: 1.0)
    }
    
    
    func setData(title:String,picture:String,price:String){
        self.goodImg?.sd_setImage(with: URL(string: "http://116.62.215.26"+picture),placeholderImage:  UIImage(named: "头像"), options: SDWebImageOptions.highPriority, completed: nil)
        self.titleLabel?.text = title
        self.priceLabel?.text = price+"积分"
    }
    
    
}
